package com.stu;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * @author MI
 * @ClassName Stram.java
 * @createTime 2021年08月26日 09:58:00
 */
public class Stram {
    @Test
    public void stream() {
        List<Us> us = new ArrayList<>();
        us.add(new Us(1, "a"));
        us.add(new Us(2, "b"));
        us.add(new Us(3, "c"));
        us.add(new Us(4, "d"));
        us.stream().forEach(vo -> vo.setName(StringUtils.repeat(vo.getName(), 5)));
        //stream 之后会改变集合
        us.forEach(System.out::println);
    }


    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Us {
        private int id;
        private String name;

        @Override
        public String toString() {
            return ToStringBuilder.reflectionToString(this, ToStringStyle.NO_CLASS_NAME_STYLE);
        }
    }

}
